package com.daimakuai.tools;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

/**
 * @author happyonion.yangtao
 * @Title: DaoTest
 * @ProjectName admin-behind
 * @PackageName test
 * @Description TODO
 * @date Create at 2018/12/2 19:15
 */

public class DaoTest {

    public static void main(String[] args) {
        SqlSessionFactory sqlSessionFactory = null;
        InputStream inputStream = null;
        SqlSession session = null;

        try {
            System.out.println(Resources.getResourceAsFile("/").getPath());
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            inputStream = Resources.getResourceAsStream("/");
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);

        } catch (IOException e) {
            e.printStackTrace();
        }


        session = sqlSessionFactory.openSession();
        List<Map<String,Object>> lists = session.selectList("com.yt.daimakuai.dao.AdminDao.listForDirtyRead");

        System.out.println(lists);

    }
}
